import React, { Component } from 'react'
// 受控组件：
// input 的value属性的值 依赖于 初始化数据，
// 必须通过 onChange 事件去修改初始化状态
export default class App extends Component {
  state = {
    username: '吴大勋'
  }
  changeHandler = (e) => {
    this.setState({
      username: e.target.value
    })
  }
  render() {
    return (
      <div>
        <input 
          onChange = { this.changeHandler }
          value = { this.state.username }
          type="text"
          placeholder ="姓"/>
        { this.state.username }
      </div>
    )
  }
}
